package com.spring.utils;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.sql.SQLException;

@Component
public class TansformThing {

    @Autowired
    private ThreddUtis threddUtis;

//    开启事务
    public void BeginThing(){
        try{
            threddUtis.getConnection().setAutoCommit(false);
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }
//    提交事务
    public void commit(){
        try {
            threddUtis.getConnection().commit();
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }
//    回滚事务
    public void rollBack(){
        try{
            threddUtis.getConnection().rollback();
        }catch (SQLException e) {
            e.printStackTrace();
        }
    }
//    清除事务
    public void releas() {threddUtis.removeThread();}
}
